package getImg

import (
	"context"
	"os"

	"server-go/api/reward/internal/svc"
	"server-go/api/reward/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HeadImgLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHeadImgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HeadImgLogic {
	return &HeadImgLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HeadImgLogic) HeadImg(req *types.HeadImgInput) (resp *types.HeadImgOut, err error) {
	imgFile, err := os.ReadFile("../public/images/" + req.UserName + ".jpg")
	if err != nil {
		return nil, err
	}
	return &types.HeadImgOut{Data: imgFile}, nil
}
